<%--
  User: my
  Date: 2020/8/4
  Time: 21:24
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>添加用户</title>
    <base href="<%=request.getContextPath()+"/"%>">
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <script type="text/javascript" src="lib/PIE_IE678.js"></script>
    <![endif]-->
    <link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
    <link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>

    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
</head>
<body>
<div class="pd-20">
    <form action="" method="post" class="form form-horizontal" id="form-admin-add">
<%--    用户名--%>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>用户名：</label>
            <div class="formControls col-5">
                <input type="text" class="input-text" value="admin" placeholder="" id="username" name="username" datatype="*2-16" nullmsg="用户名不能为空">
            </div>
            <div class="col-4"> </div>
        </div>
<%--    密码--%>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>密码：</label>
            <div class="formControls col-5">
                <input type="password" name="password" id="password" placeholder="密码" autocomplete="off" value="admin" class="input-text" datatype="*5-20" nullmsg="密码不能为空">
            </div>
            <div class="col-4"> </div>
        </div>
<%--    确认密码--%>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>确认密码：</label>
            <div class="formControls col-5">
                <input type="password"  placeholder="确认密码" recheck="password" autocomplete="off" value="admin" class="input-text" datatype="*5-20" errormsg="你两次输入的密码不一致">
            </div>
            <div class="col-4"> </div>
        </div>
<%--性别--%>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>性别：</label>
            <div class="formControls col-5 skin-minimal">
                <div class="radio-box">
                    <input type="radio" id="sex-1" name="sex" value="0" datatype="*" nullmsg="请选择性别！">
                    <label for="sex-1">男</label>
                </div>
                <div class="radio-box">
                    <input type="radio" id="sex-2" value="1" name="sex">
                    <label for="sex-2">女</label>
                </div>
            </div>
            <div class="col-4"> </div>
        </div>
<%--    年龄--%>

        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>年龄：</label>
            <div class="formControls col-5">
                <input type="text" class="input-text" value="18" placeholder="" id="age" name="age"   nullmsg="年龄不能为空">
            </div>
            <div class="col-4"> </div>
        </div>
    <%--    生日--%>
    <div class="row cl">
        <label class="form-label col-3"><span class="c-red">*</span>生日：</label>
        <div class="formControls col-5">
            <input type="text"  class="input-text" readonly="readonly" onclick="WdatePicker()" placeholder="" id="birthday" name="birthday" >
        </div>
        <div class="col-4"> </div>
    </div>
    <%--    图片--%>
    <div class="row cl">
        <label class="form-label col-3"><span class="c-red">*</span>头像：</label>
        <div class="formControls col-5">
            <input type="text" class="input-text" value="admin" placeholder="" id="image" name="image"  >
        </div>
        <div class="col-4"> </div>
    </div>
<%--    邮箱--%>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>邮箱：</label>
            <div class="formControls col-5">
                <input type="text" class="input-text" placeholder="@" name="email" id="email" datatype="e" nullmsg="请输入邮箱！">
            </div>
            <div class="col-4"> </div>
        </div>
        <div class="row cl">
            <div class="col-9 col-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</div>
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/icheck/jquery.icheck.min.js"></script>
<script type="text/javascript" src="lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="js/H-ui.js"></script>
<script language="javascript" type="text/javascript" src="/lib/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="js/H-ui.admin.js"></script>
<script type="text/javascript">
    $(function(){
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form-admin-add").Validform({
            tiptype:2,
            callback:function(form){
                debugger

                var array = form.serializeArray();
                let d={};
                for (let x of array) {
                    d[x['name']]=x['value'];
                }
                if (d){
                    $.ajax({
                        url:'user/',
                        type:'post',
                        dataType:'json',
                        data:d,
                        success:function (result) {
                            console.log(result);
                            if (result&&result['code']==200){
                                alert('添加成功');
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.$('.btn-refresh').click();
                                parent.layer.close(index);
                            }else {
                                alert('添加失败')
                            }
                        }
                    });
                }
                return false;
                // form[0].submit();

            }
        });
    });
</script>
</body>
</html>
